<% layout('/layouts/default.html', {title: '考核任务指标表管理', libs: ['dataGrid','fileupload','validate','inputmask']}){ %>
<style>

</style>
<div class="main-content">
    <div class="box box-main">
    <div class="box-body" >
        <#form:form id="searchForm" model="${dcSupExamQuotaInfo!}" action="${ctx}/quota/dcSupExamQuotaInfo/dxzbList?quotaId=${dcSupExamQuota.id!''}&quotaGroup=2" method="post" class="form-inline "
        data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize!5}" data-order-by="${parameter.orderBy}">
       </#form:form>

        <div style="float: right;">
            <a href="#"  id="plus" onclick="addQuotaInfo('${dcSupExamQuota.id}','1')" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("新增加分项")}"><i class="fa fa-plus">新增加分项</i></a>
            <a href="#"  id="reduce" onclick="addQuotaInfo('${dcSupExamQuota.id}','2')" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("新增倒扣分项")}"><i class="fa fa-plus">新增倒扣分项</i></a>
            <a href="#"  id="increase" onclick="addQuotaInfo('${dcSupExamQuota.id}','3')" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("新增单项指标")}"><i class="fa fa-plus">新增单项指标</i></a>
            <a href="#"  id="examine" onclick="auditPassed()" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("审核通过")}"><i class="fa fa-check">审核通过</i></a>
            <a href="#"  id="retreat" onclick="auditNoPassed()" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("退回")}"><i class="fa fa-reply-all">退回</i></a>
            <a href="#"  id="urge" onclick="urgeHandle()" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("催办")}">催办</a>
        </div>
    </div>
    <div class="box-header">
    </div>
    <div class="box-body">
        <div id="danxiang" style="padding-bottom: 8px"><span style ="text-decoration:underline;font-size: 20px;color: #30bbbb">单项考核指标</span></div>
        <table id="dataGrid"></table>
        <div id="dataGridPage"></div>
    </div>

    <div class=" box-body">
        <div class="ui-layout-content">
            <#form:form id="searchForm2" model="${DcSupExamSumQuotaOrg!}" action="${ctx}/quota/dcSupExamQuotaInfo/listDanOrgData" method="post" class="form-inline hide"
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize!20}"
            data-order-by="${parameter.orderBy}">
            <div class="form-group">
                <label class="control-label">${text('指标')}：</label>
                <div class="control-inline width-90">
                    <#form:input name="quotaInfoId" id="quotaInfoId" class="form-control"/>
                </div>
            </div>
        </#form:form>
        <form id="inputForm2">
        <table id="dataGrid2"></table>
        <div id="dataGrid2Page"></div>
        </form>
    </div>

</div>
<#form:form id="inputForm" model="${dcSupExamQuota}" action="${ctx}/quota/dcSupExamQuota/save" method="post" class="form-horizontal">
<p style="height: 10px"></p>
<div class="row">
    <div class="col-xs-6">
        <div class="form-group">
            <label class="control-label col-sm-4" title="">
                <span class="required hide">*</span> ${text('联系人&nbsp;&nbsp;')}：<i class="fa icon-question hide"></i></label>
            <div class="col-sm-8">
                <#form:hidden path="id" />
                <label class="control-label-left col-sm-8" id="contactName">${dcSupExamQuota.contactName}</label>
            </div>
        </div>
    </div>
    <div class="col-xs-6">
        <div class="form-group">
            <label class="control-label col-sm-4" title="">
                <span class="required hide">*</span> ${text('联系电话')}：<i class="fa icon-question hide"></i></label>
            <div class="col-sm-8">
                <label class="control-label-left col-sm-8" id="contactPhone">${dcSupExamQuota.contactPhone}</label>
                <#form:hidden path="dcSupExamQuotaInfoList" class="form-control"/>
                <#form:hidden path="createOrg" />
                <#form:hidden path="plus" />
            </div>
        </div>
    </div>
</div>
<p class="h"></p>
<div class="row">
    <div class="col-xs-12">
        <div class="form-group">
				<span class="control-label col-sm-2">
					<span class="required hide">*</span>附件上传：</span>
            <label class="control-label-left col-sm-10">
                <#form:fileupload id="uploadFile" bizKey="${dcSupExamQuota.id}" bizType="dcSupExamQuota_file"
                uploadType="all"  class="" readonly="true" preview="true"/>
            </label>
        </div>
    </div>
    <div class="col-xs-12">
        <div class="form-group">
            <label class="control-label col-sm-2">
                <span class="required hide">*</span></label>
            <div class="col-sm-10">
                <button class="btn btn-primary btn-sm" type="button" style="font-size: 14px"  id="batch">批量下载</button>
            </div>
        </div>
    </div>
</div>
</div>

</div>
</#form:form>
<% } %>
<style>
</style>
<script src="${ctxStatic}/m/js/total.js?${_version}"></script>
<script>
    var exameOrg = '${dcSupExamQuota.createOrg}';
    var submitStatus = '${dcSupExamQuota.submitStatus}';
    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        columnModel: [
            {header:'${text("指标类别")}', name:'quotaType', width:250,align:"center",
                formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_quotaType')},
                        val, '${text("未知")}', true);
                },
                unformat: function(val, obj, cell){
                    return $('#'+obj.rowId+'_quotaType').val();
                },
                editable:true, edittype:'select', editoptions:{'class':'form-control',
                    items: $.merge([{dictLabel:'&nbsp;',dictValue:''}],
                        ${@DictUtils.getDictListJson('dc_quotaType')}),
                    itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
                        $(element).select2().on("change",function(){$(this).resetValid()});
                    }
                }
            },
            {header:'${text("主键")}', name:'id', hidden:true},
            {header:'${text("序号")}', name:'sortNum', width:80, align:"center"},
            {header:'${text("指标名称")}', name:'quotaContent', index:'a.quota_content', width:350, align:"left"},

            {header:'${text("操作")}', name:'actions', width:250, align:"center",formatter: function(val, obj, row, act){
                    var actions = [];
                    actions.push('<a href="${ctx}/quota/dcSupExamQuotaInfo/form?id='+row.id+'" class="btn btn-primary btn-xs btnList" title="${text("修改")}" >修改</a>&nbsp;');
                    actions.push('<a href="${ctx}/quota/dcSupExamQuotaInfo/delete?id='+row.id+'" class="btn btn-danger btn-xs btnList" title="${text("删除")}" data-confirm="${text("确认要删除该指标吗？")}">删除</a>&nbsp;');
                    return actions.join('');
                }},
        ],
        showRownum: false,
        emptyDataHint: true,
        autoGridHeight: function(){
            return 210;
        },
        onSelectRow: function(id, isSelect, event){
            var data=$('#dataGrid').dataGrid('getRowData', id);
            $("#plus").val(data.quotaType);
            $('#quotaInfoId').val(id);
            $('#dataGrid2').dataGrid('refresh');
        },
        ajaxSuccess: function(data){
            window.parent.change(exameOrg,submitStatus);
            if(data.count=='0'){
                $("#plus").css("display","none");
                $("#reduce").css("display","none");
                $("#increase").css("display","none");
                $("#examine").css("display","none");
                $("#retreat").css("display","none");
            }
            $('#dataGrid').dataGrid('setSelectRow', $('#dataGrid').dataGrid('getSelectRows')[0], true);
        }
    });

    $('#dataGrid2').dataGrid({
        searchForm: $("#searchForm2"),
        dataGridPage: $('#dataGrid2Page'),
        autoGridHeight: function(){
            return 210;
        },
        columnModel: [
            {header:'${text("排序")}', name:'rowno',  width:100, align:"center"},
            {header:'${text("排序")}', name:'quotaInfoId',  hidden:true},
            {header:'${text("排序")}', name:'id',  hidden:true},
            {header:'${text("被考核单位")}', name:'exameOrg',  hidden:true},
            {header:'${text("quotaId")}', name:'quotaId',  hidden:true},
            {header:'${text("被考核单位名称")}', name:'exameOrgName',  width:150, align:"left"},
            {header:'${text("单位")}', name:'quotaUnit', index:'a.quota_unit', width:100, align:"center",
                editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control',
                    'placeholder':'例:亿元、万元、个、条、家、项、户等;若无则不填'},
                unformat: function(val, obj, cell){
                    return $('#'+obj.rowId+'_quotaUnit').val();
                }
            },
            {header:'${text("权数")}', name:'quotaWeight', index:'a.quota_weight', width:60, align:"center",
                editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control required dx',
                    dataInit: function(element){
                        var number=$('#'+element.id).val();
                        $(element).on("change",function(){
                            var val=$('#'+element.id).val();
                            var plus=$("#plus").val();
                            if(plus=='加分项'){
                                if(val>3){
                                    js.showMessage("加分项权数不能超过3！");
                                    $('#'+element.id).val(number);
                                }
                            }
                        });
                        $(element).on("keyup",function(){
                            $('#'+element.id).val($('#'+element.id).val().replace(/[^\d.]/g,""));
                            $('#'+element.id).val($('#'+element.id).val().replace(/^\./g,""));
                            $('#'+element.id).val($('#'+element.id).val().replace(/\.{2,}/g,"."))
                            $('#'+element.id).val($('#'+element.id).val().replace(".","$#$").replace(/\./g,"").replace("$#$","."))
                            $('#'+element.id).val($('#'+element.id).val().replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'));
                        })
                    }},
                unformat: function(val, obj, cell){
                    return $('#'+obj.rowId+'_quotaWeight').val();
                },
                formatter: function(val, obj, row, act){
                    if(val==null){
                        val=0;
                    }
                    var wg=parseFloat(val).toFixed(2);
                    return wg;
                }
            },
            {header:'${text("本年度目标")}', name:'currentYaerGoal', index:'a.current_yaer_goal', width:150, align:"center",
                editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control required dx'},
                unformat: function(val, obj, cell){
                    return $('#'+obj.rowId+'_currentYaerGoal').val();
                }
            },
            {header:'${text("考核方式")}', name:'assessMethod', index:'a.assessMethod', width:100, align:"center",
                editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control required dx'},
                formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_assessment')},
                        val, '${text("未知")}', true);
                },
                editable:true, edittype:'select', editoptions:{'class':'form-control required dx',
                    items: $.merge([], ${@DictUtils.getDictListJson('dc_exam_assessment')}),
                    itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
                        $(element).select2().on("change",function(){$(this).resetValid()});
                    }
                },
                unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();}},
            {header:'${text("备注")}', name:'remarks', index:'a.remarks', width:50, align:"center",
                editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'},
                formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_remarks')},
                        val, '${text("未知")}', true);
                },
                editable:true, edittype:'select', editoptions:{'class':'form-control required gj',
                    items: $.merge([], ${@DictUtils.getDictListJson('dc_exam_remarks')}),
                    itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
                        $(element).select2().on("change",function(){$(this).resetValid()});
                    }
                },
                unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();}},
            {header:'${text("操作")}', name:'actions', width:150, align:"center",formatter: function(val, obj, row, act){
                    var actions = [];
                    actions.push('<a href="#" onclick=xiugaiInfo("'+row.id+'")  class="btn btn-primary btn-xs xg" title="${text("修改")}" >修改</a>&nbsp;');
                    actions.push('<a href="#" onclick=updateInfo("'+row.id+'")  class="btn btn-primary btn-xs bc" style="display: none" title="${text("保存")}" >保存</a>&nbsp;');
                    actions.push('<a href="#" onclick=deleteInfo("'+row.id+'") class="btn btn-danger btn-xs" title="${text("删除")}">删除</a>&nbsp;');
                    return actions.join('');
                }},
        ],
        showRownum: false,
        // 加载成功后执行事件
        editGridInitRowNum: 0,
        emptyDataHint: true,
        editGrid: false,
        autoGridHeight: function(){
            return 800;
        },
        ajaxSuccess: function(data){

        }
    });
    function updateInfo(id) {
        let hasValid=true;
        let inputs = $("#dataGrid2").find(".dx");
        for (let i = 0; i <inputs.length; i++) {
            let has = $("#inputForm2").validate().element(inputs[i]);
            if (has==false){hasValid=false}
        }

        if (!hasValid){
            return;
        }

        let data=$('#dataGrid2').dataGrid('getRowData',$('#dataGrid2').dataGrid('getSelectRow'));
        delete data["actions"]
        let datas=$('#dataGrid').dataGrid('getRowData',$('#dataGrid').dataGrid('getSelectRow'));
        var b;
        if(datas.quotaType=='加分项'){
            js.ajaxSubmit({
                url:"${ctx}/quota/dcSupExamQuotaInfo/validationOrg",
                data:{"quotaId":data.quotaId,"quotaWeight":data.quotaWeight,"exameOrgs":data.exameOrg,"quotaType":"14","remarks":"1"},
                dataType: 'json',
                async:false,
                callback:function (data){
                    if (data.result=="false"){
                        js.showMessage(data.message);
                        b="false";
                    }else {
                        b="true";
                    }
                }
            })
        }
        if(b=='false'){
            return false;
        }
        let allData =JSON.stringify(data);
        let dcSupExamQuotaOrg ={"dcSupExamQuotaOrg":allData}
        let xg= $("#"+id).find("a")[0];
        $(xg).css("display","inline")
        let bc= $("#"+id).find("a")[1];
        $(bc).css("display","none")
        $('#dataGrid2').dataGrid('saveRow',id);

        js.ajaxSubmit({url:"${ctx}/quota/dcSupExamQuotaInfo/saveStrOrg",data:dcSupExamQuotaOrg,dataType: 'json',callback:function (data){
                if (data.result=="true"){
                    js.showMessage(data.message);
                    $('#dataGrid2').dataGrid('reloadGrid');
                }else {
                    js.showMessage(data.message);
                    $('#dataGrid2').dataGrid('reloadGrid');
                }
            }})
    }

    function xiugaiInfo(id){
        $('#dataGrid2').dataGrid('editRow', id, {keys:true, focusField:false});
        let xg= $("#"+id).find("a")[0];
        $(xg).css("display","none")
        let bc= $("#"+id).find("a")[1];
        $(bc).css("display","inline")
    }

    function deleteInfo(id){
        layer.open({
            type: 1,
            shadeClose: false,
            shade:0.6,
            title:"删除指标",
            content:'<div style="padding: 50px">您确要删除该指标吗？</div>',
            btn: ['提交','取消'],
            btn1: function(index){
                js.ajaxSubmit({url:"${ctx}/quota/dcSupExamQuotaInfo/deleteOrg",data:{"id":id},dataType: 'json',callback:function (data){
                        if (data.result=="true"){
                            js.showMessage(data.message);
                            $('#dataGrid2').dataGrid('delRowData', id);
                            $('#dataGrid2').dataGrid('reloadGrid');
                            let dataId=$('#dataGrid2').dataGrid('getRowData');
                            if(dataId.length==0){
                                var quotaId=$('#dataGrid').dataGrid('getSelectRow');
                                js.ajaxSubmit({url:"${ctx}/quota/dcSupExamQuotaInfo/delete", data:{"id":quotaId},dataType:'json',callback:function (data){
                                       if(data.result=="true"){
                                           $('#dataGrid').dataGrid('reloadGrid');
                                       }
                                  }});
                            }
                        }else {
                            js.showMessage(data.message);
                            $('#dataGrid2').dataGrid('reloadGrid');
                        }
                    }})
            },
            btn2: function (index) {
                layer.close(index);
            }
        })


    }
    //打开新的标签
    function addQuotaInfo(QuotaId,num) {
        if(num=='1'){
            js.addTabPage(null, "新增加分项指标","${ctx}/quota/dcSupExamQuotaInfo/form?quotaId="+QuotaId+"&quotaGroup=${dcSupExamQuota.quotaGroup}&exameOrg=${dcSupExamQuota.createOrg}"+"&quotaType=14&flag=1", true);
        }else if (num=='2'){
            js.addTabPage(null, "新增倒扣分项指标","${ctx}/quota/dcSupExamQuotaInfo/form?quotaId="+QuotaId+"&quotaGroup=${dcSupExamQuota.quotaGroup}&exameOrg=${dcSupExamQuota.createOrg}"+"&quotaType=13&flag=1", true);
        }else {
            js.addTabPage(null, "新增指标","${ctx}/quota/dcSupExamQuotaInfo/form?quotaId="+QuotaId+"&quotaGroup=${dcSupExamQuota.quotaGroup}&exameOrg=${dcSupExamQuota.createOrg}"+"&quotaType=11&flag=1", true);
        }
    }
    $("#btnSubmit").click(function(){
        layer.open({
            type: 1
            ,title: ['单项指标报送', 'font-size:18px; color:orange;'] //不显示标题栏
            ,btn: ['确认', '取消']
            ,btnAlign: 'c'
            ,area: '300px;'
            ,moveType: 1 //拖拽模式，0或者1
            ,content: '<div style="padding: 50px">您确定报送本次单项指标吗</div>'
            ,yes: function(layero){
                js.ajaxSubmitForm($('#inputForm'), function(data){
                    js.showMessage(data.message);
                    if(data.result == Global.TRUE){
                        js.closeCurrentTabPage(function(contentWindow){
                            contentWindow.page();
                        });
                    }
                }, "json");
            }
        });
    })

    $(function (){
       var submitStatus=`${dcSupExamQuota.submitStatus}`;
       var createOrg=`${dcSupExamQuota.createOrg}`
        if(submitStatus==''){
            $("#urge").css("display","none");
        }
       if(submitStatus=='1'){
           $("#plus").css("display","none");
           $("#reduce").css("display","none");
           $("#increase").css("display","none");
           $("#examine").css("display","none");
           $("#retreat").css("display","none");
           $("#urge").css("display","block");
       }
        if(submitStatus=='5'){
            $("#urge").css("display","none");
        }
        if(submitStatus=='3' || submitStatus=='4'){
            $("#plus").css("display","none");
            $("#reduce").css("display","none");
            $("#increase").css("display","none");
            $("#examine").css("display","none");
            $("#retreat").css("display","none");
            $("#urge").css("display","none");
            $('#dataGrid').dataGrid('hideCol', 'actions');
            $('#dataGrid2').dataGrid('hideCol', 'actions');
        }
    });
    var examTitle=`${dcSupExamQuota.examTitle}`;
    //催办功能
    // function urgeHandle() {
    //     var createOrg = `${dcSupExamQuota.createOrg}`;
    //     js.confirm("是否催办单项指标报送？", {
    //         url: '${ctx}/targetAudit/urgeInformation',
    //         data: {
    //             "createOrg":createOrg,
    //             "remarks":"单项指标",
    //             "examTitle":examTitle,
    //         },
    //         callback: function(data){
    //             js.showMessage(data.message);
    //         },
    //         dataType: 'json',
    //         async: false, message: '正在催办...',
    //         shadeClose: true }
    //     );
    // }

    function urgeHandle(){
        js.loading();
        js.layer.open({
            type: 2,
            title: ['催办'],
            area: ['800px', '400px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/targetAudit/cuibanPageDX?id=${dcSupExamQuota.examId}&org=${dcSupExamQuota.createOrg}",
            btn1: function (index, layero) {
            },
            success: function (data) {
                js.closeLoading(0, true);
            },
            end:function () {

            }
        });
    }

    //审核退回
    function auditNoPassed() {
        js.confirm("您确定要退回【"+examTitle+"】单项报送的指标吗？该操作不可恢复！", {
            url: '${ctx}/targetAudit/exameSendDXBack',
            data: {'createOrg':`${dcSupExamQuota.createOrg}`,'examId':`${dcSupExamQuota.examId}`,'noticeId':`${dcSupExamQuota.noticeId}`,'id':`${dcSupExamQuota.id}`},
            callback: function(data){
                js.showMessage(data.message);
                window.location.reload();
                window.parent.orgChange(exameOrg,'3');
            },
            dataType: 'json',
            async: false, message: '正在退回...',
            shadeClose: true }
        );
    }

    //审核通过
    function auditPassed(){
        let hasValid=true;
        let inputs = $("#dataGrid2").find(".dx");
        for (let i = 0; i <inputs.length; i++) {
            let has = $("#inputForm2").validate().element(inputs[i]);
            if (has==false){hasValid=false}
        }
        if (!hasValid){
            return;
        }
        let datagrid=$('#dataGrid').dataGrid('getRowData');
        if(datagrid.length==0){
            js.showMessage("未上报指标，无法审核通过");
            return;
        }
        js.confirm("您确定要审核通过吗？该操作不可恢复！", {
            url: '${ctx}/targetAudit/dxsaveAuditIndex',
            data: {'createOrg':`${dcSupExamQuota.createOrg}`,'examId':`${dcSupExamQuota.examId}`,'noticeId':`${dcSupExamQuota.noticeId}`,'id':`${dcSupExamQuota.id}`},
            callback: function(data){
                if (data.result=="true"){
                    //审核通过按钮
                    $("#btnPassed").css("display","none");
                    //退回按钮
                    $("#btnBack").css("display","none");
                    //催办按钮
                    $("#chuiBan").addClass("disabled");
                    //新增指标按钮
                    $("#addDataGridRowBtn").css("display","none");
                    $('#dataGrid').dataGrid('hideCol', 'actions');
                    js.showMessage(data.message);
                    window.location.reload();
                    window.parent.orgChange(exameOrg,'4');
                }else {
                    js.showMessage(data.message);
                }
            },
            dataType: 'json',
            async: false, message: '正在提交...',
            shadeClose: true }
        );
    }
   <!--文件批量下载 -->
    $("#batch").click(function (){
        var list=	$("#uploadFile").val();
        if (list == null || list == ''){
            js.showMessage("下载列表为空");
            return;
        }
        var id=	'${dcSupExamQuota.id}';
        var bizType='dcSupExamQuota_file';
        let xhr = new XMLHttpRequest();
        xhr.open('GET', "${ctx}/taskdeploy/dcSupTaskInfo/queryDownLoadDocument?id="+id+'&bizType='+bizType+"&jpgId="+list, true);
        xhr.setRequestHeader('Content-Type', `application/json`);
        xhr.responseType = 'blob';
        let that = this;
        xhr.onload = function () {
            if (this.status == 200) {
                //接受二进制文件流
                var blob = this.response;
                let downloadElement = document.createElement('a');
                let href = blob;
                if (typeof blob == 'string') {
                    downloadElement.target = '_blank';
                } else {
                    href = window.URL.createObjectURL(blob) ;//创建下载的链接
                }
                downloadElement.href = href;
                //下载后文件名
                var dateName=getNowTime();
                downloadElement.download =   "单项指标_"+dateName+".zip";
                document.body.appendChild(downloadElement)
                downloadElement.click(); //点击下载
                document.body.removeChild(downloadElement); //下载完成移除元素
                if (typeof blob != 'string') {
                    window.URL.revokeObjectURL(href); //释放掉blob对象
                }
            }else{
                js.showMessage("文件导出失败");
            }
        }
        xhr.send();
    })

    // 获取当前时间
    function getNowTime() {
        const yy = new Date().getFullYear()
        const MM = (new Date().getMonth() + 1) < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1)
        const dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
        const HH = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours()
        const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
        const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
        return yy+MM+ dd+HH+mm+ss
    }
</script>